package pack0701;

import com.sun.security.jgss.GSSUtil;

import java.util.InputMismatchException;
import java.util.Scanner;

//演示finally关键字
public class Test4 {
    public void print(){
        try{
            Scanner scan=new Scanner(System.in);
            System.out.println("请输入第一个数: ");
            int a=scan.nextInt();

            if(a<50)
                throw new MyException("数字不得小于50");
            System.out.println("请输入第二个数: ");
            int b=scan.nextInt();
            System.out.println("除法的结果: "+a/b);

        }catch(InputMismatchException | MyException e){
            System.out.println("bbbbbbbbbbbbbbbbbbb");
        }finally{
            System.out.println("我必须要执行");
        }
    }
    public void sing(){
        try{
            print();
        }catch(InputMismatchException e){
            System.out.println("抓住了输入不匹配异常");
        }
    }

    public static void main(String[] args) {
        Test4 t=new Test4();
        try{
            t.sing();
        }catch(ArithmeticException e){
            System.out.println("抓住了数字异常");
        }
        System.out.println("aaaaaaaaaaaaaaaaaa");
    }
}
